import tkinter as tk
import random
messages = [
    "多喝水哦~",
    "保持微笑呀՞˶･֊･˶՞",
    "每天都要元气满满",
    "记得吃水果",
    "保持好心情⊹꙳ ˶˙ᵕ˙˶ ⊹꙳",
    "好好爱自己₍ᐢ·ᴗ·ᐢ₎",
    "我想你了",
    "期待下一次见面",
    "金榜题名",
    "顺顺利利੭ ˙ᗜ˙ ੭",
    "早点休息(｡•o•｡∩)",
    "愿所有烦恼都消失 ˃̶͈ ꇴ ˂̶͈ ",
    "别熬夜，今天过得开心嘛๑>ᴗO๑",
    "天冷了，多穿衣服",
    "今天天气怎么样",
    "今天的你也很辛苦",
    "期待我们下次见面>ᴗoಣ",
    "在干嘛呢",
    "别熬夜",
    "愿所有梦想成真",
    "好好吃饭 ʕÖʕÖʔ ",
    "旦逢良辰，顺颂时宜",
    "见到你就很开心✌︎˶╹ꇴ╹˶✌︎",
    "你笑起来真好看 ˋˏᰔᩚˎˊ˗",
    "告诉你，我在想你",
    "时间都很珍贵",
    "你是今天的小幸运",
    "有好多事想对你说",
    "有你在就很安心✌︎' ֊'",
    "你的努力很有用ദ്ദി˶ｰ̀֊ｰ́ )✧",
    "一切都会变好୧( ⁼̴̶̤̀ω⁼̴̶̤́ )૭",
    "慢慢来ദ്ദി˶˃ ᵕ < )✧",
    "今天也为你加油",
    "你已经很棒了",
    "小挫折而已",
    "累了就停下来",
    "你的坚持，终有所得^ω^ ",
    "每天进步一点点",
    "你值得温柔对待(´ฅ•ω•ฅ`)"
]
bg_colors = ["#F690A1", "#6AB6CF", "#76F076", "#EEEE7D", "#F78798", "#83F2F2"]
def create_popup():
    msg = random.choice(messages)
    bg_color = random.choice(bg_colors)
    font_size = random.randint(10, 13)
    
    popup = tk.Toplevel(root)
    popup.title("つ♡⊂")
    popup.configure(bg=bg_color)

    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()
    x = random.randint(0, screen_width - 255)
    y = random.randint(0, screen_height - 55)
    popup.geometry(f"250x55+{x}+{y}")
    # add message label to the popup
    label = tk.Label(popup, text=msg, bg=bg_color, font=("Arial", font_size))
    label.pack(expand=True, fill='both', padx=10, pady=10)
    popup.resizable(False, False)


# --- main application ---
root = tk.Tk()
root.title("Popup Demo")
root.geometry("320x160")

# 自动弹出设置（毫秒）
POPUP_INTERVAL_MS = 100  # 每0.1秒弹出一次，可按需修改

# 自动停止设置
MAX_POPUPS = 250  # 达到此次数后停止自动弹窗
popup_count = 0

def start_auto_popups():
    """生成一个弹窗并在间隔后再次调用自身以实现循环自动弹窗。

    当达到 MAX_POPUPS 时，停止调度并在短延迟后关闭主窗口。
    """
    global popup_count
    if popup_count >= MAX_POPUPS:
        print(f"已达到 {MAX_POPUPS} 次弹窗，程序将在短暂延迟后关闭。")
        # 给最后的弹窗一点时间后关闭主窗口
        root.after(500, root.destroy)
        return

    create_popup()
    popup_count += 1
    root.after(POPUP_INTERVAL_MS, start_auto_popups)

# 延迟启动：程序启动0.1秒后开始自动弹窗
root.after(100, start_auto_popups)

root.mainloop()